package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.ShoppingCart;
import com.itheima.reggie.service.ShoppingCartService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/shoppingCart")
@Slf4j
public class ShoppingCartController {
    @Autowired
    private ShoppingCartService shoppingCartService;

    //清空购物车
    @DeleteMapping("/clean")
    public R cleanShoppingCart(){
        return shoppingCartService.cleanShoppingCart();
    }
    //取消购物车
    @PostMapping("/sub")
    public R subShoppingCart(@RequestBody ShoppingCart shoppingCart){
     return shoppingCartService.subShoppingCart(shoppingCart);
    }
    //查询购物车
    @GetMapping("/list")
    public R getAllShoppingCart(){
        return shoppingCartService.getAllShoppingCart();
    }
    //添加购物车
    @PostMapping("/add")
    public R addShoppingCart(@RequestBody ShoppingCart shoppingCart){
       return shoppingCartService.addShoppingCart(shoppingCart);
    }
}
